package com.srp.blockchain.mybatisplustest.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.srp.blockchain.mybatisplustest.entity.UserRoleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserRoleMapper extends BaseMapper<UserRoleEntity>{


    /**
     * 查询
     * @return
     */
    List<UserRoleEntity> findAll();


    @Select("<script>" +
            "SELECT " +
            "id, role_name as roleName,role_description as roleDescription FROM user_role ur"+
            "<where>" +
            "<if test='id != null'>"  +
            "and ur.id = #{id} " +
            "</if>" +
            "</where>" +
            "</script>")
    List<UserRoleEntity> findAll2(Page page,@Param("id") Integer id);
}



